package com.obtk.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.obtk.model.SysPerson;
import com.obtk.model.User;
import com.obtk.service.impl.SysPersonService;
import com.obtk.util.PageUtil;
import com.obtk.util.ResultUtil;
import com.obtk.vo.base.PageResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/sysuser")
public class SysPersonController {
    @Autowired
    private SysPersonService sysPersonService;

    @RequestMapping("/list")
    @ResponseBody
    public PageResultVo loadUsers(User user, Integer limit, Integer offset){
        PageHelper.startPage(PageUtil.getPageNo(limit, offset),limit);
        List<SysPerson> userList = sysPersonService.selectSysPerson();
        PageInfo<SysPerson> pages = new PageInfo<>(userList);
        return ResultUtil.table(userList,pages.getTotal());
    }
}
